package com.itheima.reggie.controller;

import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Setmeal;
import com.itheima.reggie.domain.SetmealDish;
import com.itheima.reggie.service.ISetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/setmeal")
@SuppressWarnings("unchecked")
public class SetmealController {

    @Autowired
    private ISetmealService setmealService;

    // h5页面套餐展示
    @GetMapping("/list")
    public ResultInfo setmealList(Long categoryId, Integer status) { // 1.接收参数

        // 2.调用service
        List<Setmeal> setmealList = setmealService.setmealList(categoryId, status);

        // 3.返回结果
        return ResultInfo.success(setmealList);

    }

    @GetMapping("/dish/{id}")
    public ResultInfo setMealDishDetails(@PathVariable Long id){

        List<SetmealDish> setmealDishes = setmealService.setMealDishDetails(id);


        return ResultInfo.success(setmealDishes);
    }
}